// 引入封装好的axios函数
import request from "@/utils/request";

import type { SkuInfoStoreModel } from "./model/detailModel";

// 枚举接口
enum Api {
  // 获取商品详情
  getGoodsDetailApi = "/item",
  // 添加购物车
  getAddToCartApi = "/cart/addToCart",
}

// 获取商品详情
export const reqGoodsDetail = (skuId: number) =>
  request.get<any, SkuInfoStoreModel>(Api.getGoodsDetailApi + `/${skuId}`);

// 添加购物车
export const reqAddToCart = (skuId: number, skuNum: string) =>
  request.post<any, null>(Api.getAddToCartApi + `/${skuId}/${skuNum}`);
